﻿using B.S.Filtration.ErrorCode;
using B.S.Filtration.Write.Api.Application.Command.AbnormalCommand;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace B.S.Filtration.Write.Api.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class AbnormalController : ControllerBase
    {
        private readonly IMediator mediator;

        public AbnormalController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        /// <summary>
        /// 异常处理添加
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<APIResult<object>> AddAbnormal(AddAbnormalCommand request)
        {
            return await mediator.Send(request);
        }
        /// <summary>
        /// 异常处理删除
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<APIResult<int>> DelAbnormal(DelAbnormalCommand request)
        {
            return await mediator.Send(request);
        }
        /// <summary>
        /// 异常处理修改
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<APIResult<int>> UpdateAbnormal(UpdateAbnormalCommand request)
        {
            return await mediator.Send(request);

        }
    }
}
